<template>
	<view class="container">
		<rich-text :nodes="content"></rich-text>
	</view>
</template>

<script>
	import { getProtocol } from '@/api/member.js'
	export default {
		data() {
			return {
				title: {
					risk_deal: '跟投使用风险提示',
					purchase_agreement: '跟投购买协议'
				},
				type: 'risk_deal',
				content: '',
				errCont: '<p style="text-align: center; font-size: 16px">加载失败</p>'
			}
		},
		onLoad(option) {
			this.type = option.type
			uni.setNavigationBarTitle({
			　　title: this.title[option.type]
			})
			this.init()
		},
		methods: {
			init: function() {
				getProtocol().then(res=> {
					if (res.code === 200) {
						this.content = res.data[this.type]
					} else {
						this.content = this.errCont
					}
				}).catch(err => {
					this.content = this.errCont
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		height: 100vh;
		background-color: #FFFFFF;
		padding: 24rpx 32rpx;
	}
</style>
